import { aggregationService } from '@/api/aggregation'

// 业务员绑定商家相关API

/**
 * 获取当前业务员信息
 * @returns {Promise}
 */
export function getSalesmanInfo() {
  return aggregationService({
    url: '/agg/user/current',
    method: 'get'
  })
}

/**
 * 提交商家审核申请
 * @param {Object} data 商家信息
 * @returns {Promise}
 */
export function submitMerchantAudit(data) {
  return aggregationService({
    url: '/agg/merchantAudit/add',
    method: 'post',
    data: data
  })
}

/**
 * 上传文件
 * @param {FormData} formData 文件数据
 * @returns {Promise}
 */
export function uploadFile(formData) {
  return aggregationService({
    url: '/agg/file/upload',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    // 确保文件上传时不被拦截器覆盖Content-Type
    transformRequest: [function (data, headers) {
      // 对于FormData，让浏览器自动设置Content-Type
      if (data instanceof FormData) {
        delete headers['Content-Type']
      }
      return data
    }]
  })
}
